package com.itcast.demo_one.kotlin

fun main() {

    val dog = Dog("旺财")
    dog.makeSound()

    val cat = Cat("小猫")
    cat.makeSound()
}

open class Animal(var name: String) {
   open fun makeSound() {
        println("$name 在发出声音")
    }
}

class Dog(name: String) : Animal(name){
    override fun makeSound() {
         super.makeSound()
        println("$name 在汪汪汪")
    }
}

class Cat(name: String) : Animal(name) {
    override fun makeSound() {
        super.makeSound()
        println("$name 在喵喵喵")
    }
}